package com.baselibrary.libs.View.TestView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SeekBar;

import com.baselibrary.libs.R;
import com.baselibrary.libs.Utils.log.LogUtils;
import com.baselibrary.libs.View.baseView.BaseView;

/**
 * Created by Administrator 于萌萌
 * 创建日期: 9:57 . 2017年03月16日
 * 描述:
 * <p>
 * <p>
 * 备注:
 */

public class ProgressView extends BaseView{


    private MyView1 mYuan;
    private SeekBar mSb;

    public ProgressView(Context context) {
        super(context);
    }

    public ProgressView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ProgressView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public int getXml() {
        return R.layout.progressview;
    }

    @Override
    public void initView(View view) {
        mYuan = (MyView1)view.findViewById(R.id.yuan);
        mSb = (SeekBar)view.findViewById(R.id.sb);



    }

    public MyView1 getYuan(){
        return mYuan;
    }
    public void setProgress(int progress){
        mYuan.setProgress(progress);
        setSbProgress(progress);
    }
    public interface ProgressCallBack{
        void onProgress(int progress);
        void onStart();
        void onStop();
    }

    public void setSbProgress(int progress){
        mSb.setProgress(progress);
    }

    public  void  setCallBack(final ProgressCallBack callBack){
        mSb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                LogUtils.i("现在进度是"+progress);
                mYuan.setProgress(progress);
                callBack.onProgress(progress);
               // mSb.setProgress(progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                LogUtils.i("开始滑动的seekBar"+seekBar);
                callBack.onStart();
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                LogUtils.i("停止滑动的seekBar"+seekBar);
                callBack.onStop();
            }
        });
    }



}
